<template>
  <div>
    <a-table
      ref="table"
      rowKey="id"
      size="middle"
      :columns="columns"
      :dataSource="gDataSource"
      :pagination="gPagination"
      @change="gHandleTableChange"
    >
      <span slot="sortCol" slot-scope="text, record, index">
        {{
          (gPagination.current - 1) * gPagination.pageSize + parseInt(index) + 1
        }}
      </span>
    </a-table>
  </div>
</template>

<script>
import { GwListMixin } from "@/mixins/GwListMixin";
import { gPostAction } from "@/api/manage";

export default {
  name: "Dc",
  mixins: [GwListMixin],
  components: {},
  data() {
    return {
      // 表头
      columns: [
        {
          title: "序号",
          dataIndex: "",
          key: "rowIndex",
          width: 50,
          scopedSlots: { customRender: 'sortCol' },
        },
        {
          title: "数据中心",
          width: 200,
          dataIndex: "name",
        },
        // {
        //   title: "服务器亚健康数量占",
        //   dataIndex: "serverCount",
        // },
        {
          title: "空调亚健康数量",
          dataIndex: "airCount",
        },
        {
          title: "UPS亚健康数量",
          dataIndex: "upsCount",
        },
        {
          title: "健康度",
          dataIndex: "subhealth",
          customRender: function (t, r, index) {
            return t ? "亚健康" : "健康";
          },
        },
      ],
      datacenterId: "",
      datacenterList: [],
      url: {
        list: "/subhealth/pageDatacenter",
      },
      optimumData: {},
      nodeSimulateData: [],
      name: "",
    };
  },
  mounted() {
    this.loadData();
  },
  methods: {
    loadData() {
      this.gQueryParam.name = "";
      if (this.name) {
        this.gQueryParam.name = this.name;
      }
      gPostAction(this.url.list, this.gQueryParam).then(
        (res) => {
          const data = res.data;
          if (data && data.list) {
            this.gDataSource = data.list;
            this.gPagination.total = data.totalCount;
          }
        }
      );
    },
  },
};
</script>

<style lang="less" scoped>
</style>
